const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const ObjectId = Schema.Types.ObjectId;

var CourseSchema = new Schema(
	{
		name: String,
		summary: String,
		price: Number,
		poster: String,
		cat: {
			// 反向引用，节约数据库查询时间
			type: ObjectId,
			ref: 'Cat'
		}
	},
	{
		timestamps: true
	}
)

module.exports = mongoose.model('Course', CourseSchema);